Skip to content

tests: a locked recorder.exe no longer hides the cmake batch case's result (TEST-CMAKE-BATCH-CLEANUP) - #1439

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
Anonymous78e:test/cmake-batch-cleanup
Dec 1, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
Anonymous78e:test/cmake-batch-cleanup

Conversation

@Anonymous78e

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-CMAKE-BATCH-CLEANUP (#14 (comment))

What and why

Part (3) of @GTAVIB4GTAVI's parallel-load finding (#14). Parts (1) and (2) are #1410 and #1002.

tests/test_build_runtime_cmake.py builds each case in tempfile.TemporaryDirectory(dir=self.base) and copies a recorder.exe into it, which a child process runs. When Windows still holds that image at cleanup (antivirus, a late handle close), shutil.rmtree raises PermissionError: [WinError 5] and that error replaces the case's own result, as reported:

PermissionError: [WinError 5] Access is denied: ...\caret^dir\tools ^ & 東京\recorder.exe

Both temp folders, the per-case one and the class one that holds the compiled recorder, now pass ignore_cleanup_errors=True (Python 3.10+; the project needs 3.12+), so the assertion stays in charge. Nothing else changes.

Tested

Windows 11 Pro 26H2, CPython 3.13.15, on main 1154976:

  • The mechanism, deterministically: a file held open inside a TemporaryDirectory whose body fails an assertion.

    exception that surfaces
    no flag (as on main) PermissionError: [WinError 32] ...
    ignore_cleanup_errors=True AssertionError: the case's own assertion
  • python -I tests/test_build_runtime_cmake.py: 1 test (27 subtests) OK in 11 s with this change.

  • scripts/check_no_game_data.py on the file: clean.

GPUs tested: n/a

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo

…esult (TEST-CMAKE-BATCH-CLEANUP)

test_build_runtime_cmake builds each case in a TemporaryDirectory and runs a
recorder.exe from it. When Windows still holds that image at cleanup,
rmtree's PermissionError replaced the case's own result. Both temp folders
now pass ignore_cleanup_errors=True, so the assertion stays in charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo
@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed 751de4d: both TemporaryDirectory calls in test_build_runtime_cmake.py now pass ignore_cleanup_errors=True, so a still-locked recorder.exe at cleanup can no longer replace (or masquerade as) a case's result: both the class-level folder and each subTest's copied recorder. Could not run the suite here (Windows-only: csc.exe and powershell.exe; on this Linux box it exits OK (skipped=1) and compiles clean); fault injection also cannot reproduce the lock here, so this is a code-reading review: I verified the mechanism by reading tempfile's routing: cleanup() forwards the flag and every raise site in rmtree's onexc, including the locked-file PermissionError branch, is behind if not ignore_errors; README pins Python 3.12+ and the ci check job runs this file on windows-latest. Leaked leonida_cmake* folders when cleanup does fail are the accepted trade-off. No findings.

AI-assisted review.

Recommendation: Merge

MoonEyes pushed a commit to MoonEyes/leonida that referenced this pull request Nov 27, 2026
…the cmake batch case's result (TEST-CMAKE-BATCH-CLEANUP)

From ProjectLeonida#1439 (head 751de4d), applied as a reviewed patch.

Co-authored-by: Anonymous78e <Anonymous78e@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@OreoFR

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR

  • Base: main 3408969a7 + PR head 751de4d16
  • Test: python -I tests/test_build_runtime_cmake.py
  • Red on main: 1 OK
  • Green with the PR: 1 OK
  • Verdict: NO RED (no recorder.exe was locked during the test)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

@zmasi

zmasi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

#1439 | head 751de4d (merged cleanly onto origin/main a3484ce) | Windows 11 (10.0.26200.9974, NTFS), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11 + NTFS)

  • Diff & safety audit: Inspected 100% of the diff (+4/-2 in tests/test_build_runtime_cmake.py) passing ignore_cleanup_errors=True to both tempfile.TemporaryDirectory calls in CMakeBatchTest. python -I scripts/check_no_game_data.py tests/test_build_runtime_cmake.py passed (rc=0).
  • Red -> Green on Windows 11 (origin/main a3484ceebc vs #1439 + origin/main):
    • Red (Windows NTFS locked .exe teardown): Verified on Windows 11 NTFS that leaving an open handle on recorder.exe inside a tempfile.TemporaryDirectory() block raises PermissionError ([WinError 32]) during __exit__ when ignore_cleanup_errors=True is omitted, masking any assertion outcome from the body, whereas TemporaryDirectory(ignore_cleanup_errors=True) exits cleanly without masking test assertions.
    • Green (#1439 + origin/main, native Windows csc.exe + cmd.exe batch matrix): python -I tests/test_build_runtime_cmake.py -> 1/1 (OK, 0 skipped, 31.23s), executing the full Windows-only CMakeBatchTest .exe / .cmd / .bat and failure-mode subtest matrix end-to-end.

@TheGeogeo

TheGeogeo commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Correction: not in main. Its squash commit 44a715d10 landed on 2026-11-27, but 00131bb85 ("main keeps its own runtime, tools and tests; the branch's variants stay on port/d3d12-nvidia") restored tests/test_build_runtime_cmake.py the same day, so main does not have this change. I took the earlier verdict from the history (git cherry and the squash title), not from the tree. Re-checked on main c22a0a732: git merge-tree --write-tree of main and this branch gives a tree that still differs from main in tests/test_build_runtime_cmake.py.

New verdict: ready for testing. It merges cleanly with main c22a0a732.

This pull request was closed on the basis of our earlier, wrong verdict. Its change is not on main, so the author or a maintainer can reopen it.

AI-assisted (Claude Code).


Earlier comment, superseded by the correction above:

Already in main: squashed as 44a715d10 (2026-11-27, "PR #1439: tests: a locked recorder.exe no longer hides the cmake batch case's result (TEST-CMAKE-BATCH-CLEANUP)"), which is in main 3535eb5c4. git cherry finds this branch's commit there, so nothing is left to merge here.

AI-assisted (Claude Code).

@MoonEyes

Copy link
Copy Markdown
Collaborator

Closing: this landed on main as 44a715d ("PR #1439: tests: a locked recorder.exe no longer hides..."), checked in main just now. Thanks for the fix!

@MoonEyes MoonEyes closed this Nov 29, 2026
@MoonEyes

MoonEyes commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Correction: I closed this as already on main, and that was wrong. Its commit did land, but 00131bb (27/11, "main keeps its own runtime, tools and tests") removed those lines again, so main does not have this change today. I tried to reopen it, but GitHub refuses: you are at this repository's open pull request limit. You can reopen it yourself once one of your PRs is merged or closed, or say here if you want a maintainer to carry it forward with your commits. Sorry for the noise.

AI-assisted: yes (checked line by line against current main)

@MoonEyes MoonEyes reopened this Nov 30, 2026

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Passing ignore_cleanup_errors=True to both tempfile.TemporaryDirectory calls in tests/test_build_runtime_cmake.py:38,96 cleanly prevents a temporarily locked recorder.exe on Windows from masking subtest results (confirmed not present on current main). Clean-room verified and MERGEABLE; holding merge until a fresh green CI pass completes on current main.

(AI-assisted review.)

@aslan2142
aslan2142 merged commit b5f2025 into ProjectLeonida:main Dec 1, 2026
3 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants